#ifndef EXPORTEXCEL2003XMLDIALOG_H
#define EXPORTEXCEL2003XMLDIALOG_H

#include <QDialog>
#include <QSqlDatabase>
#include <QDate>
#include <QFile>

namespace Ui {
class ExportExcel2003XMLDialog;
}

class ExportExcel2003XMLDialog : public QDialog
{
    Q_OBJECT

public:
    struct Task{
        int userID;
        QString userName;
        int productID;
        QString productName;
        QString orderNo;
        int componentID;
        QString componentName;
        int taskID;
        QString taskName;
        bool assets;
        bool billable;
        int clientID;
        QString clientName;
        QDateTime startTime;
        QDateTime endTime;
        QString comment;
    };
    typedef QList<Task> TaskList;

    explicit ExportExcel2003XMLDialog(QWidget *parent = 0, QSqlDatabase db=QSqlDatabase());
    ~ExportExcel2003XMLDialog();

    void accept();

private slots:
    void on_startDateEdit_dateChanged(const QDate &date);
    void on_endDateEdit_dateChanged(const QDate &date);
    void on_filePathEdit_textChanged(const QString &arg1);
    void on_browseButton_clicked();

private:
    bool noError() const;
    void collectData();
    bool write(const QString& fname);
    void writeSummarySheet(QFile& f);
    void writeUserDetailsSheet(QFile& f);

    Ui::ExportExcel2003XMLDialog *ui;
    QSqlDatabase db_;
    TaskList taskList_;
};

#endif // EXPORTEXCEL2003XMLDIALOG_H
